package cn.wolfcode.wolf2w.Exception;

import cn.wolfcode.wolf2w.exception.LogincException;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class CommonExceptionHandler {
    //用户看的错误
    @ExceptionHandler(LogincException.class)
    @ResponseBody
    public Object handlerLoginc(Exception e) {
        e.printStackTrace();
        return new JsonResult<>(JsonResult.CODE_ERROR_PARAM,e.getMessage(), null);

    }
    //用户看的错误
    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public Object handlerExt(Exception e) {
        e.printStackTrace();
        return  JsonResult.defaultError();

    }

}

